<!--
 * @AUthor: S1mple
 * @Date: 2020-12-03 11:37:07
 * @LastEditTime: 2020-12-04 20:34:51
 * @FilePath: \heima-pc\src\views\login\index.vue
-->
<template>
  <div class="login-container">
    <div class="login-form-wrap">
      <div class="login-head">
        <div class="logo"></div>
      </div>
      <!--element-ui  表单组件 -->
      <el-form class="login-form">
        <el-form-item>
          <el-input placeholder="请输入手机号" v-model="user.mobile"></el-input>
        </el-form-item>
        <el-form-item>
          <el-input placeholder="请输入验证码" v-model="user.code"></el-input>
        </el-form-item>
        <el-form-item>
          <el-checkbox v-model="user.checkFlag"
            >我已阅读并同意用户协议和隐私条款</el-checkbox
          >
        </el-form-item>
        <el-form-item>
          <el-button class="login-btn" type="primary" @click="doLogin"
            >登录</el-button
          >
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import request from '@/utils/request'
export default {
  data () {
    return {
      user: {
        mobile: '13911111111',
        code: '246810',
        checkFlag: false
      }
    }
  },
  methods: {
    doLogin () {
      // 数据校验
      if (this.user.checkFlag === false) {
        alert('请先同意协议！')
        return
      }
      // 完成数据的提交
      // request = 添加了baseURL的axios
      request({
        url: '/mp/v1_0/authorizations',
        method: 'POST',
        data: {
          mobile: this.user.mobile,
          code: this.code
        }
      })
    }
  }
}
</script>

<style scoped lang="less">
.login-container {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;

  background: url("../../assets\\login_bg.jpg") no-repeat;
  background-size: cover;
  .login-form-wrap {
    min-width: 300px;
    padding: 30px 50px 10px;
    background-color: #fff;
    .login-head {
      display: flex;
      justify-content: center;
      .logo {
        width: 200px;
        height: 57px;
        background: url("../../assets/logo_index.png") no-repeat;
        background-size: contain;
      }
    }
    /deep/ .el-form-item__content {
      text-align: left;
    }
    .login-form {
      .login-btn {
        width: 100%;
      }
    }
  }
}
</style>
